]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
portalHelper: Simplify our non-use of cache
authorBastien Nocera <hadess@hadess.net>
Thu, 23 Mar 2017 15:54:28 +0000 (16:54 +0100)
committerBastien Nocera <hadess@hadess.net>
Tue, 28 Mar 2017 12:18:25 +0000 (14:18 +0200)
Instead of using directories that we'll destroy when done, use the new
"ephemeral" data manager feature, through the JavaScript version of:
webkit_web_context_new_ephemeral()

We also throw an error on startup, in the logs, if WebKitGTK is too old.

https://bugzilla.gnome.org/show_bug.cgi?id=780453

js/portalHelper/main.js

index 84eed5754221bc87f0a48ba1f1d88c78044e68f0..f64cae49b052efdd87fc9e2c26fc8c4af9abe9e5 100644 (file)
@@ -12,7 +12,6 @@ const WebKit = imports.gi.WebKit2;
 const _ = Gettext.gettext;
 
 const Config = imports.misc.config;
-const FileUtils = imports.misc.fileUtils;
 
 const PortalHelperResult = {
     CANCELLED: 0,
@@ -141,12 +140,8 @@ const PortalWindow = new Lang.Class({
         this._doneCallback = doneCallback;
         this._lastRecheck = 0;
         this._recheckAtExit = false;
-        let cacheDir = GLib.Dir.make_tmp("gnome-shell-portal-helper-XXXXXXXX");
-        this._cacheDir = Gio.File.new_for_path(cacheDir);
 
-        let dataManager = new WebKit.WebsiteDataManager({ base_data_directory: cacheDir,
-                                                          base_cache_directory: cacheDir });
-        this._webContext = new WebKit.WebContext({ website_data_manager: dataManager });
+        this._webContext = WebKit.WebContext.new_ephemeral();
         this._webContext.set_cache_model(WebKit.CacheModel.DOCUMENT_VIEWER);
 
         this._webView = WebKit.WebView.new_with_context(this._webContext);
@@ -169,7 +164,6 @@ const PortalWindow = new Lang.Class({
 
     destroyWindow: function() {
         this.destroy();
-        FileUtils.recursivelyDeleteDir(this._cacheDir, true);
     },
 
     _syncUri: function() {
@@ -363,6 +357,11 @@ function initEnvironment() {
 function main(argv) {
     initEnvironment();
 
+    if (!WebKit.WebContext.new_ephemeral) {
+        log('WebKitGTK 2.16 is required for the portal-helper, see https://bugzilla.gnome.org/show_bug.cgi?id=780453');
+        return 1;
+    }
+
     Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
     Gettext.textdomain(Config.GETTEXT_PACKAGE);